package com.cnit1818.generator;

import java.util.Hashtable;

/**
 * Created with IntelliJ IDEA.
 * User: MaYong
 * Date: 12-11-20
 * Time: 上午10:10
 * To change this template use File | Settings | File Templates.
 */
public class MysqlTable {
    private Hashtable mysql;
    private Hashtable<String, String> jdbcType;

    public String getPath() {
        return this.getClass().getClassLoader().getResource("/").getPath();
    }

    public MysqlTable() {
        this.mysql = new Hashtable();
        mysql.put("INT", "Integer");
        mysql.put("VARCHAR", "String");
        mysql.put("DATE", "Date");
        mysql.put("DATETIME", "Date");
        mysql.put("DOUBLE", "Double");
        mysql.put("BIGINT", "Long");
        mysql.put("FLOAT", "Double");
        mysql.put("DECIMAL", "Double");
        mysql.put("TEXT", "String");
        mysql.put("CHAR", "String");

        this.jdbcType = new Hashtable();
        jdbcType.put("INT", "INTEGER");
        jdbcType.put("DATETIME", "TIMESTAMP");
    }

    public Hashtable getMysql() {
        return mysql;
    }

    public void setMysql(Hashtable mysql) {
        this.mysql = mysql;
    }

    public String getJdbcType(String key) {
        String value = this.jdbcType.get(key);
        if (value == null || value.equals("")) {
            return key;
        } else {
            return value;
        }

    }
}
